import { GpEcsWorld } from "../GpEcsWorld";
import { Comp } from "../CompDef";
import { Sglt } from "../SgltDefine";
import { MathUtils, Rectangle, Vect3 } from "../../../common/MathUtils";

import ecs, { EcsComponent } from "ecs-ts";
export class BuildingSystem extends ecs.EcsSystem<GpEcsWorld> {
    tempVec3 = new Vect3()
    uiInfo: Sglt.UiInfo
    worldInfo: Sglt.WorldInfo

    constructor(world: GpEcsWorld, defaltGroupComps: (new () => EcsComponent)[] = [Comp.Bulding]) {
        super(world, defaltGroupComps);
        this.uiInfo = this.world.getSingleton(Sglt.UiInfo)
        this.worldInfo = this.world.getSingleton(Sglt.WorldInfo)

    }

    protected onFirstUpdate(): void {
        const postOffset = 300
        // this.createBuilding(-postOffset, -postOffset, 100)
        // this.createBuilding(postOffset, postOffset, 300)
        // this.createBuilding(-postOffset, postOffset, 200)
        // this.createBuilding(postOffset, -postOffset, 150)
    }

    createBuilding(x: number, y: number, radian = 100) {
        // this.world.addEntityWithComps(
        //     [Comp.Bulding, Comp.Transform, Comp.Force, Comp.PfNode, Comp.RVOObstacle],
        //     (e) => {
        //         const transform = e.component(Comp.Transform)
        //         e.component(Comp.Force).value = 1

        //         transform.radius = radian
        //         Vec3.set(transform.pos, x, y)

        //         e.component(Comp.RVOObstacle).vertices = Obstacle.convertCircleToPolygon(transform.pos,transform.radius,8)
        //     }
        // )
        // this.world.addEntityWithComps(
        //     [Comp.Bulding, Comp.Transform, Comp.RVO, Comp.Force,Comp.PfNode],
        //     (e) => {
        //         const transform = e.component(Comp.Transform)
        //         const rvo = e.component(Comp.RVO)
        //         rvo.maxSpeed = 0
        //         e.component(Comp.Force).value = 1

        //         transform.radius = radian
        //         Vec3.set(transform.pos, x, y)
        //     }
        // )
    }

    update(): void {


    }
}